<?php

namespace app\admin\model;

use think\Model;

class Analyst extends Model
{
    // 表名
    protected $name = 'analyst';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    
    // 追加属性
    protected $append = [
        'country_text',
        'title_text'
    ];
    

    
    public function getCountryList()
    {
        return ['1' => __('Country 1'),'2' => __('Country 2'),'3' => __('Country 3')];
    }     

    public function getTitleList()
    {
        return ['1' => __('Title 1'),'2' => __('Title 2')];
    }     


    public function getCountryTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['country']) ? $data['country'] : '');
        $list = $this->getCountryList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getTitleTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['title']) ? $data['title'] : '');
        $list = $this->getTitleList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
